import pandas as pd
import time

COUNTRY_NAME = "Iran"
data_all = pd.read_excel('csv/' + COUNTRY_NAME + 'Data.xlsx', usecols=['countryName', 'province_confirmedCount',
                                                                       'province_curedCount', 'province_deadCount',
                                                                       'updateTime'])

date_last = ''
list = []
for i in range(0, data_all.values.shape[0]):
    date = str(data_all.values[i][-1]).split(' ')[0]
    if date != date_last:
        list.append(data_all.values[i])
        date_last = date
# 二维list


# list转dataframe
df = pd.DataFrame(list, columns=['国家', '确诊人数', '治愈人数', '死亡人数', '更新时间'])
# 保存到本地excel
# df.to_csv("OneDay/" + COUNTRY_NAME + "_OneDay_csv.csv")
df.to_csv( COUNTRY_NAME + "_OneDay_csv.csv")
df.to_excel(COUNTRY_NAME + "_OneDay.xlsx")
# df.to_excel("OneDay/" + COUNTRY_NAME + "_OneDay.xlsx")
